package timing.ukulele.third.controller.weixin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import timing.ukulele.common.data.ResponseData;
import timing.ukulele.data.third.data.weixin.WxAutoReplyDTO;
import timing.ukulele.data.third.view.common.EnumItemVO;
import timing.ukulele.data.third.view.weixin.WxAutoReplyVO;
import timing.ukulele.third.service.weixin.WxAutoReplyService;
import java.util.List;

/**
 * 消息自动回复
 */
@RestController
@AllArgsConstructor
@RequestMapping("/weixin/wxAutoReply")
public class WxAutoReplyController {

    private final WxAutoReplyService wxAutoReplyService;

    /**
     * /wxAutoReply/page
     * @param wxAutoReplyDTO
     * @return
     */
	@Operation(summary = "分页查询")
    @PostMapping("/page")
    public ResponseData<IPage<WxAutoReplyVO>> pageList(@RequestBody WxAutoReplyDTO wxAutoReplyDTO) {
    	return ResponseData.success(wxAutoReplyService.pageList(wxAutoReplyDTO));
    }

    /**
     * /wxAutoReply/page
     * @param id
     * @return
     */
	@Operation(summary = "通过id查询消息自动回复")
    @GetMapping("/getDetails")
    public ResponseData<WxAutoReplyVO> getDetails(@RequestParam("id") Long id) {
        return ResponseData.success(wxAutoReplyService.getDetails(id));
    }

    /**
     * /wxAutoReply/saveWxAutoReply
     * @param wxAutoReplyDTO
     * @return
     */
	@Operation(summary = "新增消息自动回复")
    @PostMapping("saveWxAutoReply")
    public ResponseData saveWxAutoReply(@RequestBody WxAutoReplyDTO wxAutoReplyDTO) {
    	return ResponseData.success(wxAutoReplyService.saveWxAutoReply(wxAutoReplyDTO));
    }

    /**
     * /wxAutoReply/updateWxAutoReply
     * @param wxAutoReplyDTO
     * @return
     */
    @Operation(summary = "修改消息自动回复")
    @PutMapping("updateWxAutoReply")
    public ResponseData updateWxAutoReply(@RequestBody WxAutoReplyDTO wxAutoReplyDTO) {
        return ResponseData.success(wxAutoReplyService.updateWxAutoReply(wxAutoReplyDTO));
    }

    /**
     * /wxAutoReply/deleteWxAutoReply
     * @param id
     * @return
     */
	@Operation(summary = "通过id删除消息自动回复")
    @DeleteMapping("/deleteWxAutoReply")
    public ResponseData<Boolean> deleteWxAutoReply(@RequestParam("id") Long id){
        return ResponseData.success(wxAutoReplyService.deleteWxAutoReply(id));
    }

    /**
     * /weixin/wxAutoReply/getWxAutoReqType
     * @return
     */
    @Operation(summary = "获取请求消息类型")
    @GetMapping("/getWxAutoReqType")
    public ResponseData<List<EnumItemVO>> getWxAutoReqType(@RequestParam("appId") String appId) {
        return ResponseData.success(wxAutoReplyService.getWxAutoReqType(appId));
    }

}
